import { getQueryVariable } from '@/utils';
//路由前置守卫拦截
export const useRouterBeforeEach = (to: any, from: any, next: any) => {
  if (to.path === '/login') {
    // 如果是登录页面则放行
    const redirectPath = getQueryVariable('redirect');
    // 如果有重定向路径，则跳转
    if (redirectPath) {
      next(redirectPath);
    } else {
      next();
    }
  } else {
    const token = localStorage.getItem('token');
    if (!token) {
      // 如果没有token，则跳转到登录页面
      next('/login?redirect=' + to.fullPath);
    }
  }
};
//路由后置守卫拦截
export const useRouterAfterEach = (to: any, from: any) => {};
